package com.gibs.peixunapi.controller;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.ObjectError;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import lombok.extern.slf4j.Slf4j;
import com.gibs.peixunapi.enums.ResultEnum;
//import com.gibs.peixunapi.config.ConfigUtils;
//import com.gibs.peixunapi.controller.Application;
import javax.transaction.Transactional;
import javax.validation.Valid;
import com.gibs.peixunapi.service.ExamInfoService;
import com.gibs.peixunapi.model.ExamInfo;
import com.gibs.peixunapi.result.Result;
import com.gibs.peixunapi.utils.ResultUtil;

/**
 * 功能：【考试】的后台控制器
 * 项目：装配式培训平台 
 * 日期：2020-08-20
 * 作者：梁嘉伟
 */

@Slf4j
@RestController
@RequestMapping("/ExamInfos")
public class ExamInfos extends Application {

	@Autowired
	private ExamInfoService ExamInfoService;

	@Transactional
	@PostMapping("/create")
	public Result create(@Valid ExamInfo object, BindingResult bindingResult) {

		Result errorList = getResult(bindingResult);
		if (errorList != null) {
			return errorList;
		}
			return ExamInfoService.create( object);
	}

	@Transactional
	@PostMapping("/save")
	public Result save(@Valid ExamInfo object, BindingResult bindingResult) {
	
			Result errorList = getResult(bindingResult);
		if (errorList != null) {
			return errorList;
		}
                        return ExamInfoService.save( object);
	
	}

	@PostMapping("/delete")
	public Result delete(Integer id) {
		
			
			 return ExamInfoService.delete(id);
		
	}

	@GetMapping("/get")
	public Result get(Integer id) {
		 return ExamInfoService.get(id);
	}

	@GetMapping("/getList")
	public Result getList(String key) {
		 return ExamInfoService.getList(key);
	}

	@GetMapping("/getListPage")
	public Result getListPage(String key, Integer current, Integer limit) {
		
		return ExamInfoService.getListPage(key, current, limit);
		
	}

	

	@GetMapping("/getOptions")
	public Result getOptions(String key) {
		return ExamInfoService.getOptions(key);
	}

	
}

